/*图标组件*/
import { h, defineComponent } from 'vue'
import * as Icon from '@ant-design/icons-vue'

export default defineComponent({
  props: {
    name: {
      type: String,
      default: '',
    },
  },
  setup(props: { name: string }) {
    // todo ant-design 专用图标
    if (props.name?.length > 2) {
      const hFun =
        Icon[
          props.name
            ?.split('-')
            .map((val) => {
              return val.substring(0, 1).toUpperCase() + val.substring(1)
            })
            .join('')
        ]
      return () => h(hFun)
    } else {
      // @ts-ignore
      return () => h(Icon[props.name])
    }
  },
})
